
<?php
define('BLOCKAUTOMADE','1.00');
/************************************************************************/
/* FrameWork  test preview                                              */
/* ==================================================================== */
/*                                                                      */
/* This program is free software. You can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 2 of the License.       */
/************************************************************************/


//*upgrade
//if (admin_isadmin() && $_GET['upgrade']=="on"){
//    $len=filesize("$path/$block/ugrade.inc");
//    download("http://www.framework.altervista.org/FrameWork/blocks/left/03_ricerca/upgrade.inc","$path/$block/ugrade.inc");
//    if ($len!=filesize("$path/$block/ugrade.inc"))include "$path/$block/ugrade.inc";
//}
//*/

// --------------------------------------------------------------------------------------------------------
// carica libemoticons e libBBcode se sono presenti

loadlib("libBBcode");
loadlib("libEmoticons");


/* solo gli amministratori registrati possono cambiare il testo dell'home page */
if ((defined('LIBGROUP') && group_getusergroup("webmaster",user_getuser())) || admin_isadmin()){
    $save=$_POST['save'];
    $datas=stripslashes($_POST['editor']);

    if (!file_exists("extras/FCKeditor/fckeditor.php")){
	if (defined('LIBBBCODE'))$datas=bb2html($datas);
	if (defined('LIBEMOTICONS'))$datas=emoticons2html($datas);
    }

    if($save!=""){
        admin_writelog("modify block");
	$fp=fopen($save,"w");
	fwrite($fp,$datas);
	fclose($fp);
    }
}
/*******************************************************************************/

/*crea la pagina di default ****************************************************/

// non sono dati riservati e vengono scritti fuori da sb nella cartella con nome $apptitle
if (!file_exists("datas/$path/$block"))mkdir("datas/$path/$block",0755);
if (!file_exists("datas/$path/$block/images"))mkdir("datas/$path/$block/images",0755);

//if (!file_exists("datas/$path/$block/images/motd.gif")){
//  copy("$path/$block/images/motd.gif","datas/$path/$block/images/motd.gif");
//}


if (!file_exists("datas/$path/$block/pagina")){
        $fp=fopen("datas/$path/$block/pagina","w");
      //Scrive il file attenzione i path devono essere assoluti per compatibilita' con FCKeditor
      fwrite($fp,str_replace("_image_path",base_path()."datas/$path/$block", @join(@file("$path/$block/default"))));
	fclose($fp);
 }
/*******************************************************************************/
// --------------------------------------------------------------------------------------------------------

//carica la lingua se esiste
$lang=lang();
switch($lang){
    case "en":
	define("_AUTOMADE","Automade");
	break;
    default;
	define("_AUTOMADE","Automade");
	break;
}

?>

 <?php structure_openBlock("table block automade",_AUTOMADE,"$path/$block"); ?>
    <p>

<?php echo join(file("datas/$path/$block/pagina")); ?>
    </p>

<?php edit_block_link($path,$block); ?>
<?php edit_code_link("$path/$block"); ?>

<?php structure_closeBlock(); ?>
